(function(_,$){
	if(!_.Changer){
		return ;
	}
	_.Changer.addHandler({
		name : "tree",
		selector : "ul[changer='tree']",
		handler : function(objs , region){
			var createNodes = function(allLi,array){
				allLi.each(function(i){
					var li = allLi.eq(i);
					var node = {
						name : li.children("span").html(),
						open : false,
						nodes : []
					};
					var config = li.attr("config");
					if(config){config = eval("("+config+")");}else{config={};}
					$.extend(node,config);
					
					var allChildLi = li.children("ul").children("li");
					if(allChildLi.size() > 0){
						createNodes(allChildLi,node.nodes);
					}
					array[i] = node;
				});
				return array;
			};
			
			objs.each(function(i){
				var current = objs.eq(i);
				current.removeAttr("changer");	//移除changer属性
				
				//配置信息
				var setting = {};
				var config = current.attr("config");
				if(config){config = eval("("+config+")");}else{config = {};}
				$.extend(setting,config);
				
				//节点信息
				var zTreeNodes = [];
				
				zTreeNodes = createNodes(current.children("li"),zTreeNodes);
				
				//初始化对象
				var zTree = current.zTree(setting, zTreeNodes);
				current.data("jDreamerObject",zTree);
				
				if(setting.endChanger){
					setting.endChanger(current,zTree);
				}
				/*
				//处理a
				var allA = current.find("a");
				allA.each(function(i){
					var a = allA.eq(i);
					var id = a.parent().attr("id");
					var node = zTree.getNodeByTId(id);
					a.attr("ajax",node.ajax);
				});
				
				_.Changer(region,["a_target_ajax","a_target_window"]);	//初始化a
				*/
			});
		}
	});
})(jDreamer,jQuery);